<?php
/*********************************************
  CPG Dragonfly™ CMS
  ********************************************
  Copyright © 2004 - 2007 by CPG-Nuke Dev Team
  http://dragonflycms.org

  Dragonfly is released under the terms and conditions
  of the GNU GPL version 2 or any later version
**********************************************/
if (!defined('ADMIN_MOD_INSTALL')) { exit; }

class News extends Installer_Module
{
	public $author;
	public $blocks;
	public $config;
	public $dbtables;
	public $description;
	public $modname;
	public $radmin;
	public $userconfig;
	public $version;
	public $website;

	public function __construct()
	{
		$this->author = 'CPG-Nuke Dev Team';
		$this->blocks = true;
		$this->bypass = false;
		$this->config = array();
		$this->dbtables = array('queue', 'stories', 'stories_cat', 'topics', 'comments');
		$this->description = 'Manage news articles that can be sorted between categories and topics';
		$this->modname = 'News';
		$this->radmin = true;
		$this->userconfig = array();
		$this->test = false;
		$this->version = '1.3';
		$this->website = 'dragonflycms.org';
	}

	public function pre_install()
	{
		return true;
	}

	public function post_install()
	{
		return true;
	}

	public function pre_upgrade($prev_version)
	{
		global $db;
		if (version_compare($prev_version, '1.3', '<'))
		{
			foreach (Client::$browserlang as $new => $old) {
				$db->query("UPDATE {$db->TBL->queue} SET alanguage='{$new}' WHERE alanguage='{$old}'");
				$db->query("UPDATE {$db->TBL->stories} SET alanguage='{$new}' WHERE alanguage='{$old}'");
			}
		}
		return true;
	}

	public function post_upgrade($prev_version)
	{
		return true;
	}

	public function pre_uninstall()
	{
		return true;
	}

	public function post_uninstall()
	{
		return true;
	}
}
